this.BX=this.BX||{};(function(t,e,s){"use strict";var i=function t(){babelHelpers.classCallCheck(this,t)};babelHelpers.defineProperty(i,"DEFAULT","ui-progressround-default");babelHelpers.defineProperty(i,"DANGER","ui-progressround-danger");babelHelpers.defineProperty(i,"SUCCESS","ui-progressround-success");babelHelpers.defineProperty(i,"PRIMARY","ui-progressround-primary");babelHelpers.defineProperty(i,"WARNING","ui-progressround-warning");var r=function t(){babelHelpers.classCallCheck(this,t)};babelHelpers.defineProperty(r,"COUNTER","COUNTER");babelHelpers.defineProperty(r,"PERCENT","PERCENT");babelHelpers.defineProperty(r,"INCIRCLE","INCIRCLE");babelHelpers.defineProperty(r,"INCIRCLECOUNTER","INCIRCLECOUNTER");babelHelpers.defineProperty(r,"NONE","NONE");var n,o,a,u,l,h;function c(t,e){p(t,e);e.add(t)}function p(t,e){if(e.has(t)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function g(t,e,s){if(!e.has(t)){throw new TypeError("attempted to get private field on non-instance")}return s}var f=new WeakSet;var d=function(){function t(e){babelHelpers.classCallCheck(this,t);c(this,f);this.options=s.Type.isPlainObject(e)?e:{};this.value=s.Type.isNumber(this.options.value)?this.options.value:0;this.maxValue=s.Type.isNumber(this.options.maxValue)?this.options.maxValue:100;this.bar=null;this.container=null;this.width=s.Type.isNumber(this.options.width)?this.options.width:100;this.lineSize=s.Type.isNumber(this.options.lineSize)?this.options.lineSize:5;this.status=null;this.statusType=s.Type.isString(this.options.statusType)?this.options.statusType:BX.UI.ProgressRound.Status.NONE;this.statusPercent="0%";this.statusCounter="0 / 0";this.textBefore=s.Type.isString(this.options.textBefore)?this.options.textBefore:null;this.textBeforeContainer=null;this.textAfter=s.Type.isString(this.options.textAfter)?this.options.textAfter:null;this.textAfterContainer=null;this.fill=false;this.finished=false;this.rotation=s.Type.isBoolean(this.options.rotation)?this.options.rotation:false;this.colorTrack=s.Type.isString(this.options.colorTrack)?this.options.colorTrack:null;this.colorBar=s.Type.isString(this.options.colorBar)?this.options.colorBar:null;this.color=s.Type.isString(this.options.color)?this.options.color:BX.UI.ProgressRound.Color.PRIMARY}babelHelpers.createClass(t,[{key:"setValue",value:function t(e){if(s.Type.isNumber(e)){this.value=e>this.maxValue?this.maxValue:e}return this}},{key:"getValue",value:function t(){return this.value}},{key:"setMaxValue",value:function t(e){if(s.Type.isNumber(e)){this.maxValue=e}return this}},{key:"getMaxValue",value:function t(){return this.maxValue}},{key:"finish",value:function t(){this.update(this.maxValue)}},{key:"isFinish",value:function t(){return this.finished}},{key:"setWidth",value:function t(e){if(s.Type.isNumber(e)){this.width=e}return this}},{key:"getWidth",value:function t(){return this.width}},{key:"setLineSize",value:function t(e){if(s.Type.isNumber(e)){this.lineSize=e>this.width/2?this.width/2:e}return this}},{key:"getLineSize",value:function t(){return this.lineSize}},{key:"setColor",value:function t(e){if(s.Type.isStringFilled(e)){if(this.container===null){this.createContainer()}s.Dom.removeClass(this.container,this.color);this.color=e;s.Dom.addClass(this.container,this.color)}return this}},{key:"setColorBar",value:function t(e){if(s.Type.isStringFilled(e)){this.colorBar=e;e="--ui-current-round-color:"+e+";";g(this,f,y).call(this,e)}return this}},{key:"setColorTrack",value:function t(e){if(s.Type.isStringFilled(e)){this.colorTrack=e;this.setFill(true);e="--ui-current-round-bg-track-color:"+e+";";g(this,f,y).call(this,e)}return this}},{key:"setFill",value:function t(e){if(this.container===null){this.createContainer()}if(s.Type.isBoolean(e)){this.fill=e;if(e===true){s.Dom.addClass(this.container,"ui-progressround-bg")}else{s.Dom.removeClass(this.container,"ui-progressround-bg")}}return this}},{key:"setRotation",value:function t(e){if(this.container===null){this.createContainer()}if(s.Type.isBoolean(e)){this.rotation=e;if(e===true){s.Dom.addClass(this.container,"ui-progressround-rotation")}else{s.Dom.removeClass(this.container,"ui-progressround-rotation")}}return this}},{key:"setTextBefore",value:function t(e){if(s.Type.isStringFilled(e)){this.textBefore=e;if(!this.textBeforeContainer){this.createTextBefore(e)}else{s.Dom.adjust(this.textBeforeContainer,{html:e})}}}},{key:"createTextBefore",value:function t(e){if(!this.textBeforeContainer&&s.Type.isStringFilled(e)){this.textBeforeContainer=s.Tag.render(n||(n=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-progressround-text-before">',"</div>\n\t\t\t"])),e)}}},{key:"getTextBefore",value:function t(){if(!this.textBeforeContainer){this.createTextBefore(this.textBefore)}return this.textBeforeContainer}},{key:"setTextAfter",value:function t(e){if(s.Type.isStringFilled(e)){this.textAfter=e;if(!this.textAfterContainer){this.createTextAfter(e)}else{s.Dom.adjust(this.textAfterContainer,{html:e})}}}},{key:"createTextAfter",value:function t(e){if(!this.textAfterContainer&&s.Type.isStringFilled(e)){this.textAfterContainer=s.Tag.render(o||(o=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="ui-progressround-text-after">',"</div>\n\t\t\t"])),e)}}},{key:"getTextAfter",value:function t(){if(!this.textAfterContainer){this.createTextAfter(this.textAfter)}return this.textAfterContainer}},{key:"setStatus",value:function t(){if(this.getStatusType()===BX.UI.ProgressRound.Status.COUNTER){s.Dom.adjust(this.status,{text:this.getStatusCounter()})}else if(this.getStatusType()===BX.UI.ProgressRound.Status.PERCENT){s.Dom.adjust(this.status,{text:this.getStatusPercent()})}else if(this.getStatusType()===BX.UI.ProgressRound.Status.INCIRCLE){s.Dom.adjust(this.status,{text:this.getStatusPercent()})}else if(this.getStatusType()===BX.UI.ProgressRound.Status.INCIRCLECOUNTER){s.Dom.adjust(this.status,{text:this.getStatusCounter()})}}},{key:"getStatus",value:function t(){if(!this.status){if(this.getStatusType()===BX.UI.ProgressRound.Status.COUNTER){this.status=s.Tag.render(a||(a=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<div class="ui-progressround-status">',"</div>\n\t\t\t\t"])),this.getStatusCounter())}else if(this.getStatusType()===BX.UI.ProgressRound.Status.INCIRCLE){this.status=s.Tag.render(u||(u=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<div class="ui-progressround-status-percent-incircle">',"</div>\n\t\t\t\t"])),this.getStatusPercent())}else if(this.getStatusType()===BX.UI.ProgressRound.Status.INCIRCLECOUNTER){this.status=s.Tag.render(l||(l=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<div class="ui-progressround-status-incircle">',"</div>\n\t\t\t\t"])),this.getStatusCounter())}else if(this.getStatusType()===BX.UI.ProgressRound.Status.PERCENT){this.status=s.Tag.render(h||(h=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t\t<div class="ui-progressround-status-percent">',"</div>\n\t\t\t\t"])),this.getStatusPercent())}else{this.status=s.Dom.create("span",{})}}return this.status}},{key:"getStatusPercent",value:function t(){if(this.maxValue===0){return"0%"}this.statusPercent=Math.round(this.getValue()/(this.getMaxValue()/100));if(this.statusPercent>100){this.statusPercent=100}return this.statusPercent+"%"}},{key:"getStatusCounter",value:function t(){if(Math.round(this.getValue())>Math.round(this.getMaxValue())){this.statusCounter=Math.round(this.getMaxValue())+" / "+Math.round(this.getMaxValue())}else{this.statusCounter=Math.round(this.getValue())+" / "+Math.round(this.getMaxValue())}return this.statusCounter}},{key:"getStatusType",value:function t(){return this.statusType}},{key:"setStatusType",value:function t(e){if(s.Type.isStringFilled(e)){this.statusType=e}}},{key:"createContainer",value:function t(){if(this.container===null){this.container=s.Dom.create("div",{props:{className:"ui-progressround"},children:[this.getTextAfter(),this.getTextBefore(),s.Dom.create("div",{props:{className:"ui-progressround-track"},children:[this.getStatus(),this.getBar()]})]});this.setStatusType(this.statusType);this.setColor(this.color);this.setRotation(this.rotation);this.setFill(this.fill);this.setColorTrack(this.colorTrack);this.setColorBar(this.colorBar)}}},{key:"getCircleFerence",value:function t(){return(this.width/2-this.lineSize/2)*2*3.14}},{key:"getCircleProgress",value:function t(){return this.getCircleFerence()-this.getCircleFerence()/this.maxValue*this.value}},{key:"getBar",value:function t(){var e=this.width/2-this.lineSize/2;this.svg=document.createElementNS("http://www.w3.org/2000/svg","svg");this.svg.setAttributeNS(null,"class","ui-progressround-track-bar");this.svg.setAttributeNS(null,"viewport","0 0 "+this.width+" "+this.width);this.svg.setAttributeNS(null,"width",this.width);this.svg.setAttributeNS(null,"height",this.width);this.progressBg=document.createElementNS("http://www.w3.org/2000/svg","circle");this.progressBg.setAttributeNS(null,"r",e);this.progressBg.setAttributeNS(null,"cx",this.width/2);this.progressBg.setAttributeNS(null,"cy",this.width/2);this.progressBg.setAttributeNS(null,"stroke-width",this.lineSize);this.progressBg.setAttributeNS(null,"class","ui-progressround-track-bar-bg");this.svg.appendChild(this.progressBg);this.progressMove=document.createElementNS("http://www.w3.org/2000/svg","circle");this.progressMove.setAttributeNS(null,"r",e);this.progressMove.setAttributeNS(null,"cx",this.width/2);this.progressMove.setAttributeNS(null,"cy",this.width/2);this.progressMove.setAttributeNS(null,"stroke-width",this.lineSize);this.progressMove.setAttributeNS(null,"stroke-dasharray",this.getCircleFerence());this.progressMove.setAttributeNS(null,"stroke-dashoffset",this.getCircleFerence());this.progressMove.setAttributeNS(null,"class","ui-progressround-track-bar-progress");this.svg.appendChild(this.progressMove);return this.svg}},{key:"animateProgressBar",value:function t(){this.svg.setAttributeNS(null,"class","task-report-circle-bar task-report-circle-bar-animate");var e=this.maxValue===0?this.getCircleFerence():this.getCircleProgress();this.progressMove.setAttributeNS(null,"stroke-dashoffset",e)}},{key:"update",value:function t(e){if(this.container===null){this.createContainer()}this.setValue(e);if(e>=this.maxValue){setTimeout(function(){s.Dom.addClass(this.container,"ui-progressround-finished")}.bind(this),300);this.finished=true}else{s.Dom.removeClass(this.container,"ui-progressround-finished");this.finished=false}this.setStatus();if(this.svg===null){this.getBar()}this.animateProgressBar()}},{key:"getContainer",value:function t(){if(this.container===null){this.createContainer()}this.animateProgressBar();return this.container}},{key:"renderTo",value:function t(e){if(s.Type.isDomNode(e)){return e.appendChild(this.getContainer())}return null}},{key:"destroy",value:function t(){s.Dom.remove(this.container);this.container=null;this.finished=false;this.textAfterContainer=null;this.textBeforeContainer=null;this.bar=null;this.svg=null;for(var e in this){if(this.hasOwnProperty(e)){delete this[e]}}Object.setPrototypeOf(this,null)}}]);return t}();function y(t){if(this.container===null){this.createContainer()}var e=this.container.getAttribute("style"),s=!e?t:e+t;this.container.setAttribute("style",s)}babelHelpers.defineProperty(d,"Color",i);babelHelpers.defineProperty(d,"Status",r);var C=s.Reflection.namespace("BX.UI");C.Progressround=d;t.ProgressRound=d;t.ProgressRoundColor=i;t.ProgressRoundStatus=r})(this.BX.UI=this.BX.UI||{},BX,BX);
//# sourceMappingURL=progressround.bundle.map.js